package org.springblade.modules.system.service.impl;


import org.springblade.modules.system.entity.ComputerType;
import org.springblade.modules.system.mapper.ComputerTypeMapper;
import org.springblade.modules.system.service.ComputerTypeService;
import org.springblade.modules.system.utils.PageBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class ComputerTypeServiceImpl implements ComputerTypeService {


    @Autowired
    private ComputerTypeMapper computerTypeMapper;

    @Override
    public PageBounds<ComputerType> openComputerTypeTable(ComputerType computerType, int currentPage, int pageSize) throws Exception {

		final int totalSize = computerTypeMapper.countByExample(computerType);
		PageBounds<ComputerType> pageBounds = new PageBounds<ComputerType>(currentPage, totalSize, pageSize);
		List<ComputerType> list = computerTypeMapper.selectByLimitPage(computerType, pageBounds.getOffset(), pageBounds.getPageSize());
		pageBounds.setPageList(list);
		return pageBounds;
    }

    @Override
    public PageBounds<ComputerType> selectByName(ComputerType computerType) {
		final int totalSize = computerTypeMapper.countByExample(computerType);
		PageBounds<ComputerType> pageBounds = new PageBounds<ComputerType>(computerType);
		List<ComputerType> list = (List<ComputerType>) computerTypeMapper.selectByName(computerType);
		pageBounds.setPageList(list);
		return pageBounds;
    }

    @Override
    public void isDelete(List<Integer> id) {
		computerTypeMapper.isDelete(id);
    }

    @Override
    public int deleteComputerTypeById(Integer id) {
        return computerTypeMapper.deleteComputerTypeById(id);
    }

    @Override
    public void deleteComputerTypeByIds(List<Integer> ids) {
		computerTypeMapper.deleteComputerTypeByIds(ids);
    }

    @Override
    public int addComputerType(ComputerType computerType) throws Exception {
        return computerTypeMapper.addComputerType(computerType);
    }

    @Override
    public int updateComputerType(ComputerType computerType) {
        return computerTypeMapper.updateComputerType(computerType);
    }

    @Override
    public ComputerType findById(Integer id) {
        return computerTypeMapper.findById(id);
    }

}
